package com.example.threadtest.utils;

/**
 * @author dzq
 * @qq 603557506
 * @create 2021-03-25 10:09
 * @desc
 */
public class NumberUtil {
    /**
     * 获取length长度的随机数字
     * @param length
     * @return
     */
    public static int getRadom(int length) {
        //获取一个随机数
        double rand = Math.random();
        //将随机数转换为字符串
        String str = String.valueOf(rand).replace("0.", "");
        //截取字符串
        String randomNumberStr = str.substring(0, length);
        return Integer.parseInt(randomNumberStr);
    }
}
